home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Source Code / Visual Basic Source Code.iso / vbsource / vidlibp / vidgrid.frm < prev    next >
Text File  |  1995-05-01  |  10KB  |  323 lines

  1. VERSION 2.00
  2. Begin Form VidGrid 
  3.    BackColor       =   &H00C0C0C0&
  4.    BorderStyle     =   0  'None
  5.    Caption         =   "Find Video Record"
  6.    ClientHeight    =   5550
  7.    ClientLeft      =   90
  8.    ClientTop       =   1545
  9.    ClientWidth     =   9435
  10.    Height          =   5955
  11.    HelpContextID   =   235
  12.    Left            =   30
  13.    LinkTopic       =   "Form1"
  14.    MaxButton       =   0   'False
  15.    MinButton       =   0   'False
  16.    ScaleHeight     =   5550
  17.    ScaleWidth      =   9435
  18.    Top             =   1200
  19.    Width           =   9555
  20.    WindowState     =   2  'Maximized
  21.    Begin TextBox txtTape 
  22.       DataField       =   "RecCode"
  23.       DataSource      =   "dtaVideo"
  24.       Height          =   615
  25.       Left            =   8595
  26.       TabIndex        =   9
  27.       TabStop         =   0   'False
  28.       Top             =   3975
  29.       Visible         =   0   'False
  30.       Width           =   645
  31.    End
  32.    Begin TextBox txtTime 
  33.       DataField       =   "RunTime"
  34.       DataSource      =   "dtaVideo"
  35.       Height          =   615
  36.       Left            =   8595
  37.       TabIndex        =   8
  38.       TabStop         =   0   'False
  39.       Top             =   3225
  40.       Visible         =   0   'False
  41.       Width           =   645
  42.    End
  43.    Begin TextBox txtYear 
  44.       DataField       =   "RlsYear"
  45.       DataSource      =   "dtaVideo"
  46.       Height          =   615
  47.       Left            =   8595
  48.       TabIndex        =   7
  49.       TabStop         =   0   'False
  50.       Text            =   " "
  51.       Top             =   2475
  52.       Visible         =   0   'False
  53.       Width           =   645
  54.    End
  55.    Begin CommandButton cmdPageForward 
  56.       Caption         =   ">"
  57.       Height          =   270
  58.       Left            =   6705
  59.       TabIndex        =   5
  60.       Top             =   375
  61.       Width           =   285
  62.    End
  63.    Begin CommandButton cmdPageBack 
  64.       Caption         =   "<"
  65.       Height          =   270
  66.       Left            =   1215
  67.       TabIndex        =   6
  68.       Top             =   375
  69.       Width           =   285
  70.    End
  71.    Begin TextBox txtName 
  72.       DataField       =   "VidName"
  73.       DataSource      =   "dtaVideo"
  74.       Height          =   615
  75.       Left            =   8595
  76.       TabIndex        =   4
  77.       TabStop         =   0   'False
  78.       Top             =   1725
  79.       Visible         =   0   'False
  80.       Width           =   645
  81.    End
  82.    Begin TextBox txtCode 
  83.       DataField       =   "VidCode"
  84.       DataSource      =   "dtaVideo"
  85.       Height          =   615
  86.       Left            =   8595
  87.       TabIndex        =   3
  88.       TabStop         =   0   'False
  89.       Top             =   975
  90.       Visible         =   0   'False
  91.       Width           =   645
  92.    End
  93.    Begin Data dtaVideo 
  94.       Connect         =   ""
  95.       DatabaseName    =   "VIDLIB.MDB"
  96.       Exclusive       =   0   'False
  97.       Height          =   270
  98.       Left            =   1485
  99.       Options         =   0
  100.       ReadOnly        =   -1  'True
  101.       RecordSource    =   "Video"
  102.       Top             =   375
  103.       Width           =   5235
  104.    End
  105.    Begin CommandButton cmdDone 
  106.       Caption         =   "&Done"
  107.       Height          =   465
  108.       HelpContextID   =   235
  109.       Left            =   8235
  110.       TabIndex        =   0
  111.       Top             =   150
  112.       Width           =   1185
  113.    End
  114.    Begin Grid grdVideo 
  115.       BackColor       =   &H00FFFF00&
  116.       Cols            =   5
  117.       FixedCols       =   0
  118.       Height          =   6090
  119.       HelpContextID   =   235
  120.       HighLight       =   0   'False
  121.       Left            =   180
  122.       TabIndex        =   1
  123.       Top             =   825
  124.       Width           =   9255
  125.    End
  126.    Begin Label lblData 
  127.       BackColor       =   &H00FFFF00&
  128.       BorderStyle     =   1  'Fixed Single
  129.       Height          =   240
  130.       Left            =   1215
  131.       TabIndex        =   2
  132.       Top             =   150
  133.       Width           =   5775
  134.    End
  135. End
  136. ' Subsystem: Edit
  137. ' Module:    VidGrid.Frm
  138. ' Date:      01/02/94
  139. ' Author:    Richard Stauch
  140. ' Notes:
  141. ' This form displays up to MAXROW rows of data from the Video
  142. ' table. The user can scroll through the data, and can select
  143. ' a row making it the current record. The current record is
  144. ' always displayed in the top row.
  145. ' The module-level variables RepoFlag, DataMove and GridFill
  146. ' work together to prevent recursion into the FillGrid procedure
  147. ' when moving through the data normally, or when a record is
  148. ' read paging up or down.
  149.  
  150. Option Explicit
  151. DefInt A-Z
  152.  
  153. ' Constants
  154. Const MAXROW = 24 ' The Maximum data rows.
  155.  
  156. ' Variables
  157. Dim RepoFlag As Integer ' Reposition flag.
  158. Dim DataMove As Integer ' Data Move flag.
  159. Dim GridFill As Integer ' Grid Fill flag.
  160.  
  161. Sub cmdDone_Click ()
  162. ' Remove the grid form, and return to the calling form.
  163.   Unload VidGrid
  164. End Sub
  165.  
  166. Sub cmdPageBack_Click ()
  167. ' Perform the MovePrevious method up to MAXROWs.
  168. Dim I As Integer  ' Counter to read MAXROWs.
  169. ' Prevent the system from filling the grid until we're done.
  170.   GridFill% = True
  171.   RepoFlag% = True
  172. ' Read backward until we reach MAXROW, or beginning-of-file.
  173.   Do Until dtaVideo.Recordset.BOF Or I% = MAXROW
  174.   ' Capture the current record code before moving.
  175.     CurrentRecordCode$ = txtCode.Text
  176.     dtaVideo.Recordset.MovePrevious
  177.     I% = I% + 1
  178.   Loop
  179. ' We have the code, now fill the grid.
  180.   GridFill% = False
  181.   RepoFlag% = False
  182.   dtaVideo.Recordset.FindFirst "VidCode = '" + CurrentRecordCode$ + "'"
  183. End Sub
  184.  
  185. Sub cmdPageForward_Click ()
  186. ' Perform the MoveNext method up to MAXROWs.
  187. Dim I As Integer  ' Counter to read MAXROWS.
  188. ' Prevent the system from filling the grid until we're done.
  189.   GridFill% = True
  190.   RepoFlag% = True
  191. ' Read forward until we reach MAXROW, or end-of-file.
  192.   Do Until dtaVideo.Recordset.EOF Or I% = MAXROW
  193.   ' Capture the current record before moving.
  194.     CurrentRecordCode$ = txtCode.Text
  195.     dtaVideo.Recordset.MoveNext
  196.     I% = I% + 1
  197.   Loop
  198. ' We have the code, now fill the grid.
  199.   GridFill% = False
  200.   RepoFlag% = False
  201.   dtaVideo.Recordset.FindFirst "VidCode = '" + CurrentRecordCode$ + "'"
  202. End Sub
  203.  
  204. Sub dtaVideo_Reposition ()
  205. ' Data control has repositioned.
  206.   If DataMove% = True And GridFill% = False Then
  207.   ' The user has clicked the data control, or we're paging.
  208.     CurrentRecordCode$ = txtCode.Text
  209.     DataMove% = False
  210.   End If
  211.   If RepoFlag% = False Then
  212.   ' Don't call FillGrid recursively.
  213.     RepoFlag% = True
  214.     FillGrid
  215.     RepoFlag% = False
  216.   End If
  217. End Sub
  218.  
  219. Sub dtaVideo_Validate (Action As Integer, Save As Integer)
  220. ' Data control Validate event.
  221.   Select Case Action
  222.     Case DATA_ACTIONUNLOAD
  223.     ' The user clicked the Done command button.
  224.       CurrentRecordCode$ = txtCode.Text
  225.     Case DATA_ACTIONMOVEFIRST, DATA_ACTIONMOVEPREVIOUS, DATA_ACTIONMOVENEXT, DATA_ACTIONMOVELAST
  226.     ' We're moving the record pointer.
  227.       DataMove% = True
  228.   End Select
  229. End Sub
  230.  
  231. Sub FillGrid ()
  232. ' Fill the grid control starting with the current record.
  233. Dim I As Integer
  234. ' Prevent the Reposition event from calling this procedure.
  235.   GridFill% = True
  236. ' Maximize the grid rows.
  237.   grdVideo.Rows = MAXROW + 1
  238. ' Begin with the current record.
  239.   dtaVideo.Recordset.FindFirst "VidCode = '" + CurrentRecordCode$ + "'"
  240. ' Point to the first column.
  241.   grdVideo.Col = 0
  242. ' Point to the first row.
  243.   I% = 0
  244.   Do Until dtaVideo.Recordset.EOF Or I% = MAXROW
  245.     I% = I% + 1 ' Increment the row counter.
  246.     grdVideo.Row = I% ' Point to the current row.
  247.   ' Now set the text of each cell with the bound control texts.
  248.     grdVideo.Text = txtCode.Text
  249.     grdVideo.Col = 1
  250.     grdVideo.Text = txtName.Text
  251.     grdVideo.Col = 2
  252.     grdVideo.Text = txtYear.Text
  253.     grdVideo.Col = 3
  254.     grdVideo.Text = txtTime.Text
  255.     grdVideo.Col = 4
  256.     grdVideo.Text = txtTape.Text
  257.     grdVideo.Col = 0 ' Reset the column.
  258.     dtaVideo.Recordset.MoveNext ' Read the next record.
  259.   Loop
  260. ' Make sure there are no blank rows.
  261.   If I% < MAXROW Then
  262.     grdVideo.Rows = I% + 1
  263.   End If
  264. ' Reset the current record.
  265.   dta